package com.fzhucc.modules.system.repository;

import com.fzhucc.modules.system.domain.UserSmall;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

/**
 * @author yyg
 */
public interface UserSmallRepository extends JpaRepository<UserSmall, Long>, JpaSpecificationExecutor<UserSmall> {


    @Query(nativeQuery = true, value = "SELECT r.* FROM sys_user as r where r.phone=:phone and r.org_area=:orgArea")
    List<UserSmall> findAllsByPhone(String phone, String orgArea);

    @Query(nativeQuery = true, value = "SELECT r.* FROM sys_user as r where r.username=:username and r.org_area=:orgArea")
    List<UserSmall> findAllsByUserName(String username, String orgArea);

    @Query(nativeQuery = true, value = "SELECT r.* FROM sys_user as r where r.username=:phone")
    List<UserSmall> findAllsByPhoneWithOutArea(String phone);

}